package weekMatch.one_342;

import com.sun.org.apache.bcel.internal.generic.NEW;
import javafx.scene.effect.SepiaTone;

import java.util.HashSet;
import java.util.Set;

public class LeeCode_02 {
    public static void main(String[] args) {
        System.out.println(sumOfMultiples(35));
    }
    private static int sumOfMultiples(int n) {
        int ans = 0;
        int tmp = 3;
        Set<Integer> set = new HashSet<>();
        while (tmp <= n){
            ans += tmp;
            set.add(tmp);
            tmp += 3;
        }
        tmp = 5;
        while (tmp <= n){
            if (!set.contains(tmp))
                ans += tmp;
            set.add(tmp);
            tmp += 5;
        }
        tmp = 7;
        while (tmp <= n){
            if (!set.contains(tmp))
                ans += tmp;
            set.add(tmp);
            tmp += 7;
        }
        return ans;
    }
}
